#include "FrontendState.h"

FrontendState::FrontendState(GameContext& gc)
	: GameState(gc)
{
}

FrontendState::~FrontendState()
{
}

void FrontendState::Load()
{
	mBackground.Load("frontend_background.jpg");

	mFont.Load(20);
	mCursor.Load("cane.png");

	mStartButton.Load("play_button_on.png", "play_button_off.png");
	mStartButton.SetPosition(SVector2(100.0f, 175.0f));

	mStartButton2.Load("help_button_on.png", "help_button_off.png");
	mStartButton2.SetPosition(SVector2(175.0f, 250.0f));

	mQuitButton.Load("exit_button_on.png", "exit_button_off.png");
	mQuitButton.SetPosition(SVector2(250.0f, 325.0f));
}

void FrontendState::Unload()
{
	mBackground.Unload();
	mFont.Unload();
	mCursor.Unload();
	mStartButton.Unload();
	mStartButton2.Unload();
	mQuitButton.Unload();
}

NextState FrontendState::Update(float deltaTime)
{
	mCursor.Update(deltaTime);
	mStartButton.Update(deltaTime);
	mStartButton2.Update(deltaTime);
	mQuitButton.Update(deltaTime);

	NextState nextState = None;
	if(mStartButton.IsPressed())
	{
		nextState = Gameplay;
		mGameContext.SetLevel(1);
	}
	else if (mStartButton2.IsPressed())
	{
		nextState = Help;
		mGameContext.SetLevel(2);
	}
	else if(mQuitButton.IsPressed())
		nextState = Quit;

	return nextState;
}

void FrontendState::Render()
{
	mBackground.Render();
	mStartButton.Render();
	mStartButton2.Render();
	mQuitButton.Render();
	mCursor.Render();
}